﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DotNetImage.Metadata.Types
{
    public class MetaTag
    {
        protected string[] Directories = {};

        /// <summary>
        /// Index to identify the frame within the file, current tag belongs to. -1 if it's an encoder-level data.
        /// </summary>
        public int FrameIndex { get; set; }

        /// <summary>
        /// Query string like /app1/{ushort=0}/{ushort=34665}/{ushort33434}
        /// </summary>
        public string QueryLocation { get; set; }
        public string ID { get; set; }
        public List<MetaTag> Children { get; set; }
        public MetaTag Parent { get; set; }
        public object Value { get; set; }

        public MetaTag(string queryLocation)
        {
            QueryLocation = queryLocation;
            Children = new List<MetaTag>();
            Parent = null;
            if (queryLocation != null)
            {
                Directories = queryLocation.Split('/');
            }
        }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("Query: ").Append(QueryLocation).Append("Frame: ").Append(FrameIndex).Append("; Value: ").Append(Value);
            return sb.ToString();
        }
    }
}
